<?php /*a:2:{s:95:"C:\application\phpStudy\PHPTutorial\WWW\magic\test\application\admin\view\orders\order_cat.html";i:1542594631;s:90:"C:\application\phpStudy\PHPTutorial\WWW\magic\test\application\admin\view\public\base.html";i:1542098545;}*/ ?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title><?php echo htmlentities($title); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/font.css" />
    <link rel="stylesheet" type="text/css" href="/static/admin/css/xadmin.css" />

    <script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/admin/lib/layui/layui.js"></script>
    <script type="text/javascript" src="/static/admin/js/global.js"></script>
    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/common/js/common.js"></script>
    <script type="text/javascript" src="/static/admin/js/xcity.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="javascript:void(0);"><?php echo htmlentities($navigate[0]); ?></a>
        <a>
          <cite><?php echo htmlentities($navigate[1]); ?></cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href.split('?')[0]);" title="刷新">
        <i class="layui-icon" style="line-height:30px">&#xe669;</i></a>
</div>

<style>
  #box {
    border: 1px solid #2cbca3;

    padding: 0 20px;

    position: relative;
  }

  #box #editOrder {
    position: absolute;
    right: 0;
    top: 0;

    z-index: 99;
  }

  #box .layui-table {
    border-bottom: 1px solid #e5e5e5;
  }

  #box th {
    background: white;
    color: #656565;
    font-weight: bold;
  }

  #box td div {
    width: 100px;

    display: inline-block;

    color: #999;
    text-align: right;
  }

  #box td span {
    color: black;
  }

  .box_table thead th {
    background: #f2f2f2 !important;

    font-weight: normal;
    font-size: 12px;
    text-align: center;
  }

  .box_table tbody td {
    font-size: 12px;
    text-align: center;
  }

  .layui-table td, .layui-table th {
    font-size: 13px;
  }
</style>
    <div class="x-body">
      <div class="layui-row">
        <div class="layui-col-md8 layui-col-md-offset2" id="box">
          <?php if($order['order_status'] == 0 && $order['pay_status'] == 0 && $order['shipping_status'] == 0): ?>
          <button class="layui-btn layui-btn" onclick="load_url('<?php echo url('orders/order_form', ['id' => $order['id']]); ?>')" id="editOrder"><i class="layui-icon">&#xe642;</i>修改订单</button>
          <?php endif; ?>
          <div class="layui-row">

            <!-- 基本信息 -->
            <table class="layui-table" lay-skin="nob">

              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
                <tr>
                  <th colspan="3">基本信息</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>
                    <div>订单 ID：</div>
                    <span><?php echo htmlentities($order['id']); ?></span>
                  </td>
                  <td>
                    <div>订单编号：</div>
                    <span><?php echo htmlentities($order['order_sn']); ?></span>
                  </td>
                  <td>
                    <div>会员：</div>
                    <span><?php echo htmlentities($order['username']); ?></span>
                  </td>
                </tr>

                <tr>
                  <td>
                    <div>E-Mail：</div>
                    <span><?php echo !empty($order['email']) ? htmlentities($order['email']) :  '无'; ?></span>
                  </td>
                  <td>
                    <div>电话：</div>
                    <span><?php echo !empty($order['u_mobile']) ? htmlentities($order['u_mobile']) :  '无'; ?></span>
                  </td>
                  <td>
                    <div>应付<?php echo !empty($order['integral']) ? '积分'  :  '金额'; ?>：</div>
                    <span><?php echo !empty($order['integral']) ? htmlentities($order['integral']) : htmlentities($order['order_amount']); ?></span>
                  </td>
                </tr>

                <tr>
                  <td>
                    <div>订单状态：</div>
                    <span>
                      <?php switch($order['order_status']): case "0": ?>未确定<?php break; case "1": ?>已确定<?php break; case "2": ?>已收货<?php break; case "3": ?>已取消<?php break; case "4": ?>已完成<?php break; case "5": ?>已作废<?php break; ?>
                      <?php endswitch; ?>
                      /
                      <?php echo $order['pay_status']==1 ? '已支付'  :  '未支付'; ?>
                      /
                      <?php if($order['shipping_status'] == 1): ?>
                        已发货
                      <?php elseif($order['shipping_status'] == 2): ?>
                        部分发货
                      <?php else: ?>
                        未发货
                      <?php endif; ?>
                    </span>
                  </td>
                  <td>
                    <div>下单时间：</div>
                    <span><?php echo htmlentities(date("Y-m-d H:i",!is_numeric($order['add_time'])? strtotime($order['add_time']) : $order['add_time'])); ?></span>
                  </td>
                  <td>
                    <div>支付时间：</div>
                    <span><?php if($order['pay_time']): ?><?php echo htmlentities(date("Y-m-d H:i",!is_numeric($order['pay_time'])? strtotime($order['pay_time']) : $order['pay_time'])); else: ?>无<?php endif; ?></span>
                  </td>
                </tr>

                <tr>
                  <td>
                    <div>支付方式：</div>
                    <span><?php echo !empty($order['pay_name']) ? htmlentities($order['pay_name']) :  '无'; ?></span>
                  </td>
                  <td>
                    <div>发票抬头：</div>
                    <span><?php echo !empty($order['invoice_title']) ? htmlentities($order['invoice_title']) :  '无'; ?></span>
                  </td>
                  <td>
                    <div>纳税人识别号：</div>
                    <span><?php echo !empty($order['taxpayer']) ? htmlentities($order['taxpayer']) :  '无'; ?></span>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- 收货信息 -->
            <table class="layui-table" lay-skin="nob">
              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
              <tr>
                <th colspan="3">收货信息</th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>
                  <div>收货人：</div>
                  <span><?php echo htmlentities($order['consignee']); ?></span>
                </td>
                <td>
                  <div>联系方式：</div>
                  <span><?php echo htmlentities($order['mobile']); ?></span>
                </td>
                <td>
                  <div>邮编：</div>
                  <span><?php echo htmlentities($order['zipcode']); ?></span>
                </td>
              </tr>
              <tr>
                <td colspan="3">
                  <div>配送方式：</div>
                  <span><?php echo !empty($order['shipping_name']) ? htmlentities($order['shipping_name']) :  '无'; ?></span>
                </td>
              </tr>
              <tr>
                <td colspan="3">
                  <div style="text-align: right;">收货地址：</div>
                  <span><?php echo htmlentities($order['province']); ?> <?php echo htmlentities($order['city']); ?> <?php echo htmlentities($order['district']); ?> <?php echo htmlentities($order['address']); ?></span>
                </td>
              </tr>
              <tr>
                <td colspan="3">
                  <div>用户留言：</div>
                  <span><?php echo htmlentities($order['user_note']); ?></span>
                </td>
              </tr>
              </tbody>
            </table>

            <!-- 商品信息 -->
            <table class="layui-table" lay-skin="nob">
              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
                <tr>
                  <th colspan="3">商品信息</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>
                    <table class="layui-table box_table" lay-skin="line" style="margin: 0;">
                      <thead>
                        <tr>
                          <th>商品编号</th>
                          <th>商品</th>
                          <th>规格属性</th>
                          <th>数量</th>
                          <th>单品价格</th>
                          <?php if(!$order['integral']): ?>
                          <th>会员折扣价</th>
                          <?php endif; ?>
                          <th>单品小计</th>
                        </tr>
                      </thead>
                      <tbody>
                        <?php if(is_array($order['goods']) || $order['goods'] instanceof \think\Collection || $order['goods'] instanceof \think\Paginator): $i = 0; $__LIST__ = $order['goods'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
                        <tr>
                          <td><?php echo htmlentities($v['goods_sn']); ?></td>
                          <td>
                            <img src="<?php echo config('imgRoute'); ?><?php echo htmlentities($v['original_img']); ?>" style="width: 30px; height: 30px;" alt="">
                            <?php echo htmlentities($v['goods_name']); ?>
                          </td>
                          <td><?php echo htmlentities($v['spec_key_name']); ?></td>
                          <td><?php echo htmlentities($v['goods_num']); ?></td>
                          <td><?php echo !empty($v['goods_integral']) ? htmlentities($v['goods_integral']) : htmlentities($v['goods_price']); ?></td>
                          <?php if(!$v['goods_integral']): ?>
                          <td><?php echo htmlentities($v['member_goods_price']); ?></td>
                          <?php endif; ?>
                          <td><?php echo !empty($v['goods_integral']) ? htmlentities($v['goods_integral']) : htmlentities($v['member_goods_price'] * $v['goods_num']); ?></td>
                        </tr>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                      </tbody>
                    </table>
                  </td>
                </tr>
                <tr>
                  <td colspan="7" style="text-align: right;">
                    订单总额：<?php if(!$order['integral']): ?>￥<?php echo htmlentities($order['total_amount']); else: ?><?php echo htmlentities($order['integral']); ?><?php endif; ?>
                  </td>
                </tr>
              </tbody>
            </table>

            <!-- 费用信息 -->
            <table class="layui-table" lay-skin="nob">
              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
              <tr>
                <th colspan="3">
                  费用信息
                  <?php if($order['order_status'] == 0 && $order['pay_status'] == 0 && $order['shipping_status'] == 0): ?>
                  <button class="layui-btn layui-btn-normal layui-btn-xs"  onclick="load_url('<?php echo url('orders/order_cost', ['id' => $order['id']]); ?>')" ><i class="layui-icon">&#xe642;</i>修改费用</button>
                  <?php endif; ?>
                </th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>
                  <div>小计：</div>
                  <span><?php echo !empty($order['integral']) ? htmlentities($order['integral']) : htmlentities($order['goods_price']); ?></span>
                </td>
                <td>
                  <div>运费：</div>
                  <span>+<?php echo htmlentities($order['shipping_price']); ?></span>
                </td>
                <td>
                  <div>优惠券抵扣：</div>
                  <span>-<?php echo htmlentities($order['coupon_price']); ?></span>
                </td>
              </tr>

              <tr>
                <td>
                  <div>价格调整：</div>
                  <span><?php echo $order['discount']>=0 ? '+'  :  '-'; ?><?php echo htmlentities($order['discount']); ?></span>
                </td>
                <td colspan="2">
                  <div>应付：</div>
                  <span><?php echo htmlentities($order['order_amount']); ?></span>
                </td>
              </tr>
              </tbody>
            </table>

            <!-- 操作信息 -->
            <table class="layui-table" lay-skin="nob">
              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
              <tr>
                <th colspan="3">操作信息</th>
              </tr>
              </thead>
              <tbody>
                  <tr>
                    <td colspan="3">
                      <form class="layui-form">
                        <input type="hidden" name="status_desc" value="">
                        <input type="hidden" name="order_id" value="<?php echo htmlentities($order['id']); ?>">
                        <input type="hidden" name="action_user" value="<?php echo htmlentities(app('session')->get('user.id')); ?>">
                        <div style="width: 100%;">
                          <div style="float: left;">操作备注：</div>
                          <textarea placeholder="请输入操作备注" id="action_note" name="action_note" class="layui-textarea" style="width: 60%; float: left; margin: 0 0 6px 4px;"></textarea>
                        </div>

                        <div>可执行操作：</div>
                        <?php if($order['order_status'] != 5): if($order['order_status'] != 3 && ($order['pay_status'] != 1 || $order['order_status'] == 0)): ?>
                          <button class="layui-btn" lay-filter="add1" lay-submit="" data-name="pay_status" data-val="<?php echo $order['pay_status']==1 ? 0  :  1; ?>"><?php echo $order['pay_status']==1 ? '设为未付款'  :  '付款'; ?></button>
                          <?php endif; if($order['pay_status'] == 1 && $order['order_status'] == 0): ?>
                            <button class="layui-btn" lay-filter="add1" lay-submit="" data-name="order_status" data-val="1">确定</button>
                          <?php elseif($order['order_status'] == 1 && $order['pay_status'] == 1): if($order['shipping_status'] != 1): ?>
                              <button class="layui-btn" lay-filter="add1" lay-submit="" data-name="order_status" data-val="0">取消确定</button>
                              <button class="layui-btn" lay-filter="local" lay-submit="">去发货</button>
                            <?php endif; ?>
                          <?php endif; ?>
                          <button class="layui-btn" lay-filter="add1" lay-submit="" data-name="order_status" data-val="5">无效</button>
                          <?php else: ?>
                          <button class="layui-btn" lay-filter="del" lay-submit="" data-val="<?php echo htmlentities($order['id']); ?>">移除</button>
                        <?php endif; ?>
                      </form>
                    </td>
                  </tr>
              </tbody>
            </table>

            <!-- 操作记录 -->
            <table class="layui-table" lay-skin="nob">
              <colgroup>
                <col width="33%">
                <col width="33%">
                <col width="33%">
              </colgroup>
              <thead>
              <tr>
                <th colspan="3">操作记录</th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>
                  <table class="layui-table box_table" lay-skin="line" style="margin: 0;">
                    <thead>
                    <tr>
                      <th>操作者</th>
                      <th>操作时间</th>
                      <th>订单状态</th>
                      <th>付款状态</th>
                      <th>发货状态</th>
                      <th>描述</th>
                      <th>备注</th>
                    </tr>
                    </thead>
                    <tbody>
                      <?php if(is_array($order['action']) || $order['action'] instanceof \think\Collection || $order['action'] instanceof \think\Paginator): $i = 0; $__LIST__ = $order['action'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?>
                      <tr>
                        <td><?php if($v['action_user'] == 0): ?>用户：<?php echo htmlentities($order['username']); else: ?>管理员：<?php echo htmlentities($v['username']); ?><?php endif; ?></td>
                        <td><?php echo htmlentities(date("Y-m-d H:i",!is_numeric($v['log_time'])? strtotime($v['log_time']) : $v['log_time'])); ?></td>
                        <td><?php if($v['order_status'] == 1): ?>已确定<?php elseif($v['order_status'] == 5): ?>废除订单<?php else: ?>待确定<?php endif; ?></td>
                        <td><?php echo $v['pay_status']==1 ? '已支付'  :  '未支付'; ?></td>
                        <td><?php echo $v['shipping_status']==1 ? '已发货'  :  '未发货'; ?></td>
                        <td><?php echo htmlentities($v['status_desc']); ?></td>
                        <td><?php echo htmlentities($v['action_note']); ?></td>
                      </tr>
                      <?php endforeach; endif; else: echo "" ;endif; ?>
                    </tbody>
                  </table>
                </td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>

<script>
    $(function (){
        layui.use('form', function(){
            var form = layui.form;

            form.on('submit(add1)', function(data){
                let url = "<?php echo url('orders/order_cat'); ?>";
                let json = data.field;
                let name = data.elem.dataset.name;
                let code = data.elem.dataset.val;

                json.pay_status = '<?php echo htmlentities($order['pay_status']); ?>';
                json.order_status = '<?php echo htmlentities($order['order_status']); ?>';
                json.shipping_status = '<?php echo htmlentities($order['shipping_status']); ?>';

                let status_desc = '';
                switch (name){
                    case 'order_status':
                        status_desc = code == 1 ? '确认订单' :  code == 0 ? '取消确定' : '废除订单';
                        break;
                    case 'pay_status':
                        status_desc = code == 1 ? '付款成功' : '取消付款';
                        break;
                    case 'shipping_status':
                        status_desc = code == 1 ? '确认发货' : '取消发货';
                        break;
                }

                json[name] = code;
                json.status_desc= status_desc;

                data.field.__token__ = $("input[name='__token__']",top.window.document).val();
                $.post(url, data.field, function(res){
                    if(res.code == 0){
                        dialog(res.msg, false, 0, function (){
                            $("input[name='__token__']",top.window.document).val(res.data.token);
                        });
                    }else if(res.code == 1){
                        dialog(res.msg, res.url, 0, function (){
                            $("input[name='__token__']",top.window.document).val(res.data.token);
                        }, true);
                    }
                }, 'json');

                return false;
            });

            form.on('submit(del)', function(data){
                let url = "<?php echo url('orders/order_del'); ?>";

                let json = {};
                json['__token__'] = $("input[name='__token__']",top.window.document).val();
                json.order_id = data.elem.dataset.val;
                json.action_user = data.field.action_user;
                json.pay_status = '<?php echo htmlentities($order['pay_status']); ?>';
                json.order_status = '<?php echo htmlentities($order['order_status']); ?>';
                json.shipping_status = '<?php echo htmlentities($order['shipping_status']); ?>';

                json.status_desc= '删除订单';

                $.post(url, json, function(res){
                    if(res.code == 0){
                        dialog(res.msg, false, 0, function (){
                            $("input[name='__token__']",top.window.document).val(res.data.token);
                        });
                    }else if(res.code == 1){
                        dialog(res.msg, res.url, 0, function (){
                            parent.location.reload();
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        }, true);
                    }
                }, 'json');

                return false;
            });

            form.on('submit(local)', function(data){
                window.location.href = '<?php echo url("orders/order_deliver", ["id" => $order['id']]); ?>';

                return false;
            });
        });
    })

</script>


<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    /*用户-停用*/
    function member_stop(obj,id,url){
        var title = $(obj).attr('title');
        var status = $(obj).data('status');

        layer.confirm('确认要'+ title +'吗？',function(index){
            var token = $("input[name='__token__']",top.window.document).val();
            $.post(url, {'status': status, '__token__': token, 'id': id}, function(res){
                if(res.code == 1){
                    var title = '停用',icon = '&#xe601;',text = '已启用',expr = 6;
                    if(res.data.status == 0){
                        title = '启用';
                        icon = '&#xe62f;';
                        text = '已停用';
                        expr = 5;

                        $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html(text);
                        $(obj).data('status', '1');
                    }else{
                        $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html(text);
                        $(obj).data('status', '0');
                    }
                }else{
                    text = res.msg;
                }

                $(obj).attr('title',title)
                $(obj).find('i').html(icon);

                layer.msg(text,{icon: expr,time:1000});

                var token = $("input[name='__token__']",top.window.document).val(res.data.token);
            }, 'json');
        });
    }

    /*用户-删除*/
    function member_del(obj,id, url, fn = false){
        layer.confirm('确认要删除吗？',function(index){
            var token = $("input[name='__token__']",top.window.document).val();
            //发异步删除数据
            $.post(url, {'id': id, '__token__': token},function(res){
                var icon = 2;
                if(res.code == 1){
                    $(obj).parents("tr").remove();
                    icon = 1;
                }
                $("input[name='__token__']",top.window.document).val(res.data.token);
                layer.msg(res.msg, {icon:icon,time:1000}, function(){
                    if(fn)fn();
                });

            },'json');
        });
    }

    function delAll (url) {
        var data = tableCheck.getData();
        var token = $("input[name='__token__']",top.window.document).val();

        layer.confirm('确认要删除吗？'+data,function(index){
            //捉到所有被选中的，发异步进行删除
            $.post(url, {'id': data, '__token__': token},function(res){
                var icon = 2;
                if(res.code == 1){
                    $(".layui-form-checked").not('.header').parents('tr').remove();
                    icon = 1;
                }
                $("input[name='__token__']",top.window.document).val(res.data.token);
                layer.msg(res.msg, {icon:icon,time:1000});
            },'json');
        });
    }

    // 跳转地址
    function load_url(url){
        window.location.href = url;
    }

</script>
<script>var _hmt = _hmt || []; (function() {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>